package com.sctvcloud.zhaohua_sd.ui.adapter.holder;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.ruihang.generalibrary.ui.adapter.holder.BaseRecylerHolder;
import com.ruihang.generalibrary.ui.widget.CustomEXImageView;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.ruihang.generalibrary.utils.DateUtils;
import com.sctvcloud.zhaohua_sd.R;
import com.sctvcloud.zhaohua_sd.beans.NewsItem;
import com.sctvcloud.zhaohua_sd.ui.adapter.CommonFrgAdapter;
import com.sctvcloud.zhaohua_sd.ui.utils.GlideUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/23 0023.
 */

public class SpecialFrgHolder extends BaseRecylerHolder<NewsItem> implements View.OnClickListener {
    @BindView(R.id.tv_item_special)
    protected CustomFontTextView title;
    @BindView(R.id.iv_item_special)
    protected CustomEXImageView img;

    private NewsItem mNewsItem;

    public SpecialFrgHolder(Context context, View itemView) {
        super(context, itemView);
        itemView.setOnClickListener(this);
    }

    @Override
    protected void initInject() {
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(NewsItem newsItem) {
        mNewsItem = newsItem;
        title.setText(TextUtils.isEmpty(newsItem.getNewsTitle()) ? "" : newsItem.getNewsTitle());
        if (!TextUtils.isEmpty(newsItem.getNewsImage())) {
            GlideUtil.getGlideWithMid169DefNoFit(context, newsItem.getNewsImage()).into(img);

        }
    }

    @Override
    public void onClick(View v) {
        if (internalClick != null) {
            itemView.setTag(R.id.adapter_item_data_key, mNewsItem);
            internalClick.onItemInternalClick(itemView, v, getAdapterPosition());
        }
    }
}
